#!/usr/bin/env bash
# step 1: 安装必要的一些系统工具
sudo apt update -y
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common gnupg

# step 2: 安装GPG证书
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -

# Step 3: 写入软件源信息
# 添加docker的APT源到/etc/apt/sources.list.d/docker.list
echo \
    "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] http://mirrors.aliyun.com/docker-ce/linux/debian \
    "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable"
# 修改 docker.gpg 的权限为只读
chmod a+r /etc/apt/keyrings/docker.gpg
# 更新apt软件包列表
apt update -y

# Step 4: 更新并安装Docker-CE
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \
    apparmor docker-ce-rootless-extras libslirp0 slirp4netns \
    apparmor-profiles-extra apparmor-utils cgroupfs-mount

